target:=demo
sources:=$(wildcard *.c)
objects:=$(subst .c,.o,$(sources))
tinySHDir:=./tinySH
tinySHLib:=$(tinySHDir)/libtinySH.a

CFLAGS?=-g

all:$(target)

$(target) : $(objects) $(tinySHLib)
	$(CC) $(CFLAGS) -o $@ $(objects) -L$(tinySHDir) -ltinySH

$(tinySHLib):
	$(MAKE) -C $(tinySHDir) CFLAGS=$(CFLAGS)

.PHONY: all clean distclean

clean:
	-$(RM) $(objects)
	-$(RM) $(tinySHLib)
	$(MAKE) -C $(tinySHDir) clean

distclean: clean
	-$(RM) $(target)
	$(MAKE) -C $(tinySHDir) distclean
